package com.twu.biblioteca.model;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by davecroman on 19/09/2014.
 */
public class UserAccount {

    private String libraryNumber;
    private String password;
    private String name;
    private String emailAddress;
    private String phoneNumber;

    private List<BorrowableAsset> itemsBorrowed;

    public UserAccount(String libraryNumber, String password){
        this.libraryNumber = libraryNumber;
        this.password = password;
        this.itemsBorrowed = new ArrayList<BorrowableAsset>();
    }

    public UserAccount setName(String name){
        this.name = name;
        return this;
    }

    public UserAccount setEmail(String email){
        this.emailAddress = email;
        return this;
    }

    public UserAccount setPhoneNumber(String phoneNumber){
        this.phoneNumber = phoneNumber;
        return this;
    }

    public String getName() {
        return name;
    }

    public String getEmailAddress() {
        return emailAddress;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    @Override
    public String toString(){
        return String.format("User Information:\nName: %s\nEmail: %s\nPhone: %s\n", name, emailAddress, phoneNumber);
    }

    public List<BorrowableAsset> getBorrowedItems(){
        return Collections.unmodifiableList(itemsBorrowed);
    }

    public void addToBorrowedItems(BorrowableAsset item){
        itemsBorrowed.add(item);
    }

    public void removeFromBorrowedItems(BorrowableAsset item){
        itemsBorrowed.remove(item);
    }
}
